Date.prototype.Format = function(fmt){ 
	//author: meizz   
	var o = {   
			"M+" : this.getMonth()+1,                 //月份   
			"d+" : this.getDate(),                    //日   
			"h+" : this.getHours(),                   //小时   
			"m+" : this.getMinutes(),                 //分   
			"s+" : this.getSeconds(),                 //秒   
			"q+" : Math.floor((this.getMonth()+3)/3), //季度   
			"S"  : this.getMilliseconds()             //毫秒   
	};   
	if(/(y+)/.test(fmt))   
		fmt=fmt.replace(RegExp.$1, (this.getFullYear()+"").substr(4 - RegExp.$1.length));   
	for(var k in o)   
		if(new RegExp("("+ k +")").test(fmt))   
			fmt = fmt.replace(RegExp.$1, (RegExp.$1.length==1) ? (o[k]) : (("00"+ o[k]).substr((""+ o[k]).length)));   
	return fmt;   
};

function getDateTimeFromStr(dateStr)
{
	if(dateStr==''||dateStr==undefined)
		return '';
	
	var a=dateStr.split(" ");
	var d=a[0].split("-");
	var t=a[1].split(":");
	return new Date(d[0],(d[1]-1),d[2],t[0],t[1],t[2]);
}

/**禁止右击菜单，文本选择*/
function uiForbid(){
	$(document).bind("contextmenu",function(){return false;});
	$(document).bind("selectstart",function(){return false;});
}

var Common={
		parseUrl:function(url){
			//http://www.cnblogs.com/kevinge/archive/2010/07/14/1777067.html
			 var a =  document.createElement('a');
			    a.href = url;
			    return {
			        source: url,
			        protocol: a.protocol.replace(':',''),
			        host: a.hostname,
			        port: a.port,
			        query: a.search,
			        params: (function(){
			            var ret = {},
			                seg = a.search.replace(/^\?/,'').split('&'),
			                len = seg.length, i = 0, s;
			            for (;i<len;i++) {
			                if (!seg[i]) { continue; }
			                s = seg[i].split('=');
			                ret[s[0]] = s[1];
			            }
			            return ret;
			        })(),
			        file: (a.pathname.match(/\/([^\/?#]+)$/i) || [,''])[1],
			        hash: a.hash.replace('#',''),
			        path: a.pathname.replace(/^([^\/])/,'/$1'),
			        relative: (a.href.match(/tps?:\/\/[^\/]+(.+)/) || [,''])[1],
			        segments: a.pathname.replace(/^\//,'').split('/')
			    };
		},
		getUrl:function(action){
			var urls=this.urls,baseUrl=this.config.baseUrl;
			if(urls[this.operateCode]&&this.urls[this.operateCode][action])
				return baseUrl+urls[this.operateCode][action];
			else if(urls[action])
				return baseUrl+urls[action];
			else 
				return baseUrl+action;
		},
		subStringAfterLast:function(str,separator){
			if(!str||!separator)
				return str;
			var index=str.lastIndexOf(separator);
			if(index==-1)
				return str;
			else 
				return str.substring(index+1,str.length);
		},
		hasDuplicate:function(array){
			var map={},duplicate=[];
			for(var i=0;i<array.length;i++)
			{
				if(!array[i])
					continue;
				if(map[array[i]])
					map[array[i]]++;
				else
					map[array[i]]=1;
			}
			for(i in map)
				if(map[i]>1)
					duplicate.push(i);
			return duplicate;
		}
};

function jump(url,params,$ele,id){
	id=id||'jump-form-temp-id';
	$ele=$ele||$('body');
	$('#'+id,$ele).remove();
	html=[];
	html.push('<div style="display:none">');
	html.push('	<form class="jump-form" action="'+url+'" name="'+id+'-form" id="'+id+'" method="post">');
	for(var key in params)
		html.push('		<input type="hidden" name="'+key+'" value="'+params[key]+'">');
	html.push('	</form> ');
	html.push('</div>');
	$ele.append(html.join(""));
	$('#'+id,$ele).submit();
}

var bingding={
		clickPropertiesBind:function(inputEle,value){
			if(inputEle.value!=null)
				$(inputEle).val(value);
			else
				$(inputEle).html(value!=null?value:'');
			/*if(inputEle instanceof HTMLInputElement)
				$(inputEle).val(value);
			else if(inputEle instanceof HTMLSelectElement||inputEle instanceof HTMLTextAreaElement)
				$(inputEle).val(value);
			else//文本,HTMLTableCellElement,HTMLTextAreaElement
				$(inputEle).html(value!=null?value:'');*/
		},
		inputBindModel:function(inputEleSelector,fun){
			$.each($(inputEleSelector),function(index,ele){
				if(ele instanceof HTMLInputElement||ele instanceof HTMLTextAreaElement)
				{
					if(ele.type=='radio'||ele.type=='check')
						$(ele).on('change',fun);
					else	
						$(ele).on('keyup',fun);
				}	
				else if(ele instanceof HTMLSelectElement)
					$(ele).on('change',fun);	
			});			
		}
	};

//兼容问题：
if(!String.prototype.trim)
{
	String.prototype.trim=function(){
		return this.replace(/(^\s*)|(\s*$)/g, "");
	};
}	

/*Function.prototype.bind= Function.prototype.bind
|| function(){
  var fn = this, presetArgs = [].slice.call(arguments); 
  var context = presetArgs.shift();
  return function(){
    return fn.apply(context, presetArgs.concat([].slice.call(arguments)));
  };
};
*/

if(!Function.prototype.bind){ 
	var _bound = function(){ 
	if (this instanceof bound){ 
	var ctor = function(){}; 
	ctor.prototype = fn.prototype; 
	var self = new ctor(); 
	fn.apply(self, presetArgs.concat([].slice.call(arguments))); 
	return self; 
	} 
	return fn.apply(context, presetArgs.concat([].slice.call(arguments))); 
	} 
	, _boundStr = _bound.toString(); 
	Function.prototype.bind = function(){ 
	var fn = this, presetArgs = [].slice.call(arguments); 
	var context = presetArgs.shift(); 
	var strOfThis = fn.toString(); // 函数反序列化，用于获取this的形参 
	var fpsOfThis = /^function\s*\w*\(([^)]*)\)/mg.exec(strOfThis)[1].trim().split(',');// 获取this的形参 
	var lengthOfBound = Math.max(fn.length - presetArgs.length, 0); 
	var boundArgs = lengthOfBound && fpsOfThis.slice(presetArgs.length) || [];// 生成bound的形参 
	// 通过函数反序列和字符串替换动态定义函数 
	var bound = eval('(0,' + _boundStr.replace('function()', 'function(' + boundArgs.join(',') + ')') + ')'); 
	return bound; 
	};
}

if (!Array.prototype.map) {

	  Array.prototype.map = function(callback, thisArg) {

	    var T, A, k;

	    if (this == null) {
	      throw new TypeError(' this is null or not defined');
	    }

	    // 1. Let O be the result of calling ToObject passing the |this| 
	    //    value as the argument.
	    var O = Object(this);

	    // 2. Let lenValue be the result of calling the Get internal 
	    //    method of O with the argument "length".
	    // 3. Let len be ToUint32(lenValue).
	    var len = O.length >>> 0;

	    // 4. If IsCallable(callback) is false, throw a TypeError exception.
	    // See: http://es5.github.com/#x9.11
	    if (typeof callback !== 'function') {
	      throw new TypeError(callback + ' is not a function');
	    }

	    // 5. If thisArg was supplied, let T be thisArg; else let T be undefined.
	    if (arguments.length > 1) {
	      T = thisArg;
	    }

	    // 6. Let A be a new array created as if by the expression new Array(len) 
	    //    where Array is the standard built-in constructor with that name and 
	    //    len is the value of len.
	    A = new Array(len);

	    // 7. Let k be 0
	    k = 0;

	    // 8. Repeat, while k < len
	    while (k < len) {

	      var kValue, mappedValue;

	      // a. Let Pk be ToString(k).
	      //   This is implicit for LHS operands of the in operator
	      // b. Let kPresent be the result of calling the HasProperty internal 
	      //    method of O with argument Pk.
	      //   This step can be combined with c
	      // c. If kPresent is true, then
	      if (k in O) {

	        // i. Let kValue be the result of calling the Get internal 
	        //    method of O with argument Pk.
	        kValue = O[k];

	        // ii. Let mappedValue be the result of calling the Call internal 
	        //     method of callback with T as the this value and argument 
	        //     list containing kValue, k, and O.
	        mappedValue = callback.call(T, kValue, k, O);

	        // iii. Call the DefineOwnProperty internal method of A with arguments
	        // Pk, Property Descriptor
	        // { Value: mappedValue,
	        //   Writable: true,
	        //   Enumerable: true,
	        //   Configurable: true },
	        // and false.

	        // In browsers that support Object.defineProperty, use the following:
	        // Object.defineProperty(A, k, {
	        //   value: mappedValue,
	        //   writable: true,
	        //   enumerable: true,
	        //   configurable: true
	        // });

	        // For best browser support, use the following:
	        A[k] = mappedValue;
	      }
	      // d. Increase k by 1.
	      k++;
	    }

	    // 9. return A
	    return A;
	  };
	}

if (!Array.prototype.filter){
    Array.prototype.filter = function(fun /*, thisArg */){
        "use strict";
        if (this === void 0 || this === null)
            throw new TypeError();
        var t = Object(this);
        var len = t.length >>> 0;
        if (typeof fun !== "function")
            throw new TypeError();
        var res = [];
        var thisArg = arguments.length >= 2 ? arguments[1] : void 0;
        for (var i = 0; i < len; i++){
            if (i in t){
                var val = t[i];
                if (fun.call(thisArg, val, i, t))
                res.push(val);
            }
        }
        return res;
    };
}

//Production steps of ECMA-262, Edition 5, 15.4.4.18
//Reference: http://es5.github.io/#x15.4.4.18
if (!Array.prototype.forEach) {  
 Array.prototype.forEach = function(fun /*, thisp*/){  
     var len = this.length;  
     if (typeof fun != "function")  
         throw new TypeError();  
     var thisp = arguments[1];  
     for (var i = 0; i < len; i++){  
         if (i in this)  
             fun.call(thisp, this[i], i, this);  
     }  
 };  
}

var DONT_ENUM =  "propertyIsEnumerable,isPrototypeOf,hasOwnProperty,toLocaleString,toString,valueOf,constructor".split(","),
hasOwn = ({}).hasOwnProperty;
for (var i in {
    toString: 1
}){
    DONT_ENUM = false;
}

Object.keys = Object.keys || function(obj){//ecma262v5 15.2.3.14
    var result = [];
    for(var key in obj ) if(hasOwn.call(obj,key)){
        result.push(key) ;
    }
    if(DONT_ENUM && obj){
        for(var i = 0 ;key = DONT_ENUM[i++]; ){
            if(hasOwn.call(obj,key)){
                result.push(key);
            }
        }
    }
    return result;
};